package com.changxianggu.cloud.edu.tool.controller;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.Stage;

/**
 * @author liuyuantao
 */
public class LoginController {
    /**
     * 连接地址
     */
    @FXML
    public TextField conUrl;
    /**
     * 登录用户名
     */
    @FXML
    public TextField userName;
    /**
     * 密码
     */
    @FXML
    public PasswordField password;
    /**
     * 数据库名
     */
    @FXML
    public TextField dbName;

    @FXML
    public ComboBox emsCombobox;
    /**
     * 错误提示信息
     */
    @FXML
    private Label errorMsg;

    @FXML
    private Button loginBtn;

    public void doLogin(ActionEvent actionEvent) {
        errorMsg.setText("连接地址没有填写!");
        System.out.println(conUrl.getText());
        System.out.println(userName.getText());
        System.out.println(password.getText());
        System.out.println(dbName.getText());
        System.out.println(emsCombobox.getValue());
        System.out.println(emsCombobox.getVisibleRowCount());
        Stage stage = (Stage) loginBtn.getScene().getWindow();
        stage.close();
        openPlatformWindow();
    }

    private void openPlatformWindow() {
        try {
            Parent platform = FXMLLoader.load(getClass().getResource("../../../../../../resources/fxml/platform.fxml"));
            Stage platformStage = new Stage();
            platformStage.setTitle("教学计划查询");
            platformStage.setResizable(false);
            platformStage.setScene(new Scene(platform, 1060, 600));
            platformStage.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
